@extends('admin.layout.common')
@section('content')
<link rel="stylesheet" type="text/css" href="{{URL::asset('css/finance/Inform.css')}}">
	<div class="content">
		<h1>财务分账中心</h1>
		<table border="1" align="center">
			<thead>
				<tr>
					<th>报表id</th>
					<th>分账周期</th>
					<th>分账类型</th>
					<th>分账总金额</th>
					<th>操作</th>
				</tr>
			</thead>
			@foreach($list as $v)
			@if($v->music_status == 3)
			<tr>
				<td>{{$v->id}}</td>
				<td>{{$v->time}}</td>
				<td>音乐人分账</td>
				<td>{{$v->music_total}}</td>
				<td>
					<button type="button" class="layui-btn layui-btn-radius layui-btn-primary" onclick="sendmusic({{$v->id}})">发送账单</button>
				</td>
			</tr>
			@endif
			@if($v->agent_status == 3)
			<tr>
				<td>{{$v->id}}</td>
				<td>{{$v->time}}</td>
				<td>代理分账</td>
				<td>{{$v->agent_total}}</td>
				<td>
					<button type="button" class="layui-btn layui-btn-radius layui-btn-primary" onclick="sendagent({{$v->id}})">发送账单</button>
				</td>
			</tr>
			@endif
			@if(!empty($v->appoint_total))
			@if($v->appoint_status == 3)
			<tr>
				<td>{{$v->id}}</td>
				<td>{{$v->time}}</td>
				<td>指定人分账</td>
				<td>{{$v->appoint_total}}</td>
				<td>
					<button type="button" class="layui-btn layui-btn-radius layui-btn-primary" onclick="sendappoint({{$v->id}})">发送账单</button>
				</td>
			</tr>
			@endif
			@endif
			@endforeach
		</table>
		
	</div>
<script>
        // 发送账单
	    function sendmusic($id) {
            layer.confirm('发送通知后，用户将收到财务报表，确定发送？', {
                btn: ['确定','取消'] //按钮
            }, function (index, layero) {
                    $.get('http://{{$_SERVER['HTTP_HOST']}}/admin/changeInformMusic/' + $id, function (data) {
                        layer.msg('发送成功', {icon: 1});
                        location.reload();
                    })
                }, function(){
                layer.msg('已取消发送', {
                    time: 2000, //2s后自动关闭
                    btn: ['确定','取消']
                });
            });
		}
		// 发送账单
	    function sendagent($id) {
            layer.confirm('发送通知后，用户将收到财务报表，确定发送？', {
                btn: ['确定','取消'] //按钮
            }, function (index, layero) {
                    $.get('http://{{$_SERVER['HTTP_HOST']}}/admin/changeInformAgent/' + $id, function (data) {
                        layer.msg('发送成功', {icon: 1});
                        location.reload();
                    })
                }, function(){
                layer.msg('已取消发送', {
                    time: 2000, //2s后自动关闭
                    btn: ['确定','取消']
                });
            });
		}
		// 发送账单
	    function sendappoint($id) {
            layer.confirm('发送通知后，用户将收到财务报表，确定发送？', {
                btn: ['确定','取消'] //按钮
            }, function (index, layero) {
                    $.get('http://{{$_SERVER['HTTP_HOST']}}/admin/changeInformAppoint/' + $id, function (data) {
                        layer.msg('发送成功', {icon: 1});
                        location.reload();
                    })
                }, function(){
                layer.msg('已取消发送', {
                    time: 2000, //2s后自动关闭
                    btn: ['确定','取消']
                });
            });
		}
</script>
@endsection